﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GenerationCode.CSClasses
{
    class ExtendDataAccess
    {
        private Utils.Table table;
        private string projectName;
        private string coder;
        private string email;
        private string objectClass;       
        public ExtendDataAccess(Utils.Table tb, string projectname, string coder, string email)
        {
            this.table = tb;
            this.projectName = projectname;
            this.coder = coder;
            this.email = email;           
        }
        //set header 
        private string SetHeader()
        {
            string header = string.Format(@"/*
Author : {0}
Email  : {1}
Date   : {2} 

*/

using System;
using System.Collections.Generic;
using System.Text;
using log4net;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Common;
using {3};
using {4};
using System.Xml;
        
namespace {5}{6}
      /// <summary>
    /// Define {7}Dao class. This class inherit from  {7}DaoBase class.
    /// If you want add new function, you must define here.
    /// </summary>
    public class {7}Dao:{7}DaoBase {6}
    private static ILog logger = null;",
                this.coder, this.email, DateTime.Now.ToShortDateString(), Utils.Utility.UtilityNamespace, Utils.Utility.BusinessObjectNamespace, Utils.Utility.DataAccessNamespace,
                 "{", this.table.Name);
            return header;
        }




        //set contructor
        private string SetConstructor()
        {
            string constructor = string.Format(@"
            #region Constructor
              /// <summary>
            /// Define Constructor.
             /// </summary>
            public {0}Dao(){1}{2}", table.Name, "{", "}");
            constructor += string.Format(@"
             static {0}Dao()
            {1}
            // Init logger.
            logger = LoggingUtility.GetLogger(typeof({0}Dao).FullName);
            {2}", table.Name, "{", "}");            
            return constructor;

        }








        private string SetFooter()
        {
            string footer = @"           
	}
}";
            footer += "\r\n #endregion";
            return footer;
        }
        public string ObjectClass
        {
            get
            {
                this.objectClass = this.SetHeader() + this.SetConstructor() + SetFooter();
                return this.objectClass;
            }
        }



    }
}
